package sanrenxing.dayEnd.backRepertoryTotal.controller;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import sanrenxing.dayEnd.backRepertoryTotal.domain.SettingOfSecurities;
import sanrenxing.dayEnd.backRepertoryTotal.service.impl.SettingOfSecuritiesBizImpl;

import java.util.HashMap;
import java.util.Map;

/**
 * 功能：券商控制器类
 * 编写者：蒋玲苹
 * 日期：
 * 版本：1.0
 */
@RestController
@RequestMapping("/settingOf")
public class SettingOfSecuritiesController {
    /*定义业务层接口*/
    @Autowired
    private SettingOfSecuritiesBizImpl settingOfSecuritiesBiz;

    @GetMapping("/setting")
    public Map<String,Object> queryAll(int page, int limit, SettingOfSecurities settingOfSecurities){
        Map<String,Object> map=new HashMap<>();
        map.put("code",0);
        map.put("msg","");
        map.put("count",settingOfSecuritiesBiz.count(settingOfSecurities));
        map.put("data",settingOfSecuritiesBiz.queryAll(settingOfSecurities,limit,(page-1)*limit));
        return map;
    }
    //添加数据
    @PostMapping("/setting")
    public String addSetting(@RequestBody SettingOfSecurities settingOfSecurities) {
        int rows=settingOfSecuritiesBiz.add(settingOfSecurities);
        return rows>0?"add success":"failure";
    }

    //删除数据
    @DeleteMapping("/setting/{str}")
    public String deleteSetting(@PathVariable String str){
        //调用业务层删除数据
        int rows=settingOfSecuritiesBiz.delete(str);
        return rows>0?"delete success":"delete failure";
    }
    //修改数据
    @PutMapping("/setting")
    public String updateSetting(@RequestBody SettingOfSecurities settingOfSecurities){
        //调用业务层修改数据
        int rows=settingOfSecuritiesBiz.update(settingOfSecurities);
        return rows>0?"update success":"update failure";
    }
}
